import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import ElementUI from 'element-ui';
import Treeselect from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
import 'element-ui/lib/theme-chalk/index.css';
import draggable from './utils/draggable';
import proj4 from 'proj4';
import { register } from 'ol/proj/proj4';
import '../src/assets/css/YousheBiaoTiHei.css';
// proj4.defs("szbj54", "+proj=tmerc +lat_0=0 +lon_0=120.583333 +k=1 +x_0=50805.000000 +y_0=-3421129.000000 +a=6378245 +b=6356863.01877305 +towgs84=148.309000,218.731000,86.562000,-1.497800,4.016600,-3.591800,-6.447825 +units=m +no_defs")
proj4.defs("sz2000", "+proj=tmerc +lat_0=0 +lon_0=120.783333 +k=1 +x_0=350000.000000 +y_0=-2800000.000000 +ellps=GRS80 +towgs84=202.821824,122.007590,-2.931627,-2.114703,3.359609,-6.553252,-1.354140 +units=m +no_defs")
register(proj4);
Vue.prototype.$proj4 = proj4;
Vue.config.productionTip = false
Vue.use(ElementUI);
Vue.use(draggable);
Vue.component('Treeselect', Treeselect); // 注册组件

//拖拽弹窗
Vue.directive('drag', {
  inserted(el, binding) {
    Vue.nextTick(() => {
      const handle = el.querySelector('.drag-handle') || el;
      handle.style.cursor = 'move';

      let isDragging = false;
      let offsetX, offsetY;

      handle.onmousedown = function (e) {
        isDragging = true;
        offsetX = e.pageX - el.offsetLeft;
        offsetY = e.pageY - el.offsetTop;

        document.onmousemove = function (e) {
          if (isDragging) {
            el.style.position = 'absolute';
            el.style.left = `${e.pageX - offsetX}px`;
            el.style.top = `${e.pageY - offsetY}px`;
          }
        };

        document.onmouseup = function () {
          isDragging = false;
          document.onmousemove = null;
          document.onmouseup = null;
        };
      };
    });
  }
});

Vue.use(Treeselect);
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')

